<template>
  <section class="container">
    <div>
      <logo/>
      <el-table :data="tableData" style="width: 100%">
        <el-table-column prop="Type" label="类型" width="100"></el-table-column>
        <el-table-column prop="Content" label="内容" width="300"></el-table-column>
        <el-table-column prop="PublishTime" label="时间" width="300"></el-table-column>
      </el-table>
    </div>
  </section>
</template>

<script>
import Logo from "~/components/Logo.vue";
import axios from "axios";
// import * as data from "./data.json";

export default {
  components: {
    Logo
  },
  head() {
    return {
      title: "nuxt",
      meta: [
        {
          hid: "nuxt hid",
          name: "nuxt name",
          content: "My nuxt description"
        }
      ]
    };
  },
  data() {
    return {
      tableData: []
    };
  },
  created(){
    // console.log('json数据',data);
  },
  asyncData({ params }) {
    axios.defaults.headers.common["Authorization"] =
      "Basic dWp1ejpmb2xsb3d1cA==";
    axios.defaults.baseURL =
      "https://api-beta.yjyz.com/erp.followup.srv/api/v1/followup";

    if (process.server) {
      return axios.get("/search", {
          params: {
            Type: "二手房",
            Index: 1,
            Limit: 50,
            OrderBy: 0,
            Content: "",
            CityCode: 450124
          }
        })
        .then(response => {
          console.log("获取http1", response.data["data"]["list"]);
          return { tableData: response.data["data"]["list"] };
        })
        .catch(function(error) {
          console.log(error);
        });
    }
  },
  methods: {
    goOrder() {
      this.$router.push("/order");
    }
  }
};
</script>

<style>
.container {
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
}

.title {
  font-family: "Quicksand", "Source Sans Pro", -apple-system, BlinkMacSystemFont,
    "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  display: block;
  font-weight: 300;
  font-size: 100px;
  color: #35495e;
  letter-spacing: 1px;
}

.subtitle {
  font-weight: 300;
  font-size: 42px;
  color: #526488;
  word-spacing: 5px;
  padding-bottom: 15px;
}

.links {
  padding-top: 15px;
}
</style>
